<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>register</title>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<script>
	$.validator.setDefaults({
	    submitHandler: function() {
	      alert("提交事件!");
	    }
	});
	
	$().ready(function() {
		// 提交时验证表单
		var validator = $("#form1").validate({
			errorPlacement: function(error, element) {
				// Append error within linked label
				$( element )
					.closest( "p" )
//						.find( "label[for='" + element.attr( "id" ) + "']" )
							.append( error );
			},
			errorElement: "span",
			messages: {
				user: {
					required: " (必需字段)",
					minlength: " (不能少于 3 个字母)"
				},
				password: {
					required: " (必需字段)",
					minlength: " (字母不能少于 5 个且不能大于 12 个)",
					maxlength: " (字母不能少于 5 个且不能大于 12 个)"
				}
			}
		});
	
		$(".cancel").click(function() {
			validator.resetForm();
		});
	});
          $(function(){
          	$('.submit').click(function(){
          		var data = {
          			account : $('#account').val(),
          			password : $('#password').val(),
          			phone : $('#phone').val(),
          			mail : $('#mail').val(),
          			username : $('#username').val()
          		}
          		
          		$.post('http://10.3.136.12//course/api/api/student/Register',data,function(response){
          			console.log(response);
          		})
          	});
          	
          	$('#download').click(function(){
          		$.get('http://10.3.136.12//course/api/api/file/DownLoad?account=梁荣富&password=LIANG24685hong')
          	})
          })
	</script>
<style>
.error{
	color:red;
}
label{
	width: 100px;
	display: inline-block;
}
</style>
</head>
<body>
<form method="get" class="cmxform" id="form1" action="">
  <fieldset>
    <legend>注册框</legend>
    <p>
      <label for="account">account</label>
      <input id="account" name="account" required minlength="3">
    </p>
    <p>
      <label for="password">passworld</label>
      <input id="password" type="password" required >
    </p>
    <p>
      <label for="phone">phone</label>
      <input id="phone" type="text" required>
    </p>
    <p>
      <label for="mail">mail</label>
      <input id="mail" type="text" required>
    </p>
    <p>
      <label for="username">username</label>
      <input id="username" type="text"  required >
    </p>
    <p>
      <input class="submit" type="button" value="Register">
      <input type="button" name="download" id="download" value="获取" />
    </p>
  </fieldset>
</form>
</body>
</html>
